package edu.gatech.cs2340.OregonTrail;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import edu.gatech.cs2340.OregonTrail.EventSystem.CommCoordinator;

public class Shop {
	
	private String locationName;
	private Map<Item, Integer> shopInventory;
	
	/**
	 * @return the shopInventory
	 */
	public Map<Item, Integer> getShopInventory() {
		return shopInventory;
	}

	public Shop(Region newRegion, Map<Item,Integer> newInventory, CommCoordinator comm, String locationName){
		shopInventory = newInventory;
		
		this.locationName = locationName;
	}
	
	public boolean inStock(Map<Item,Integer> itemList){
		Iterator<Item> it = itemList.keySet().iterator();
		Item nextItem = null;
		while(it.hasNext()){
			nextItem = it.next();
			if(shopInventory.containsKey(nextItem)){
				if(shopInventory.get(nextItem) < itemList.get(nextItem)){
					return false;
				}
			}
			else{
				return false;
			}
		}
		return true;
	}
	
	public Map<Item, Integer> getShopPrices() {
		Map<Item, Integer> prices = new HashMap<Item, Integer>();
		Iterator<Item> it = shopInventory.keySet().iterator();
		Item nextItem = null;
		while(it.hasNext()){
			nextItem = it.next();
			prices.put(nextItem, nextItem.getBaseCost());
		}
		return prices;
	}
	
	public String getLocationName(){
		return locationName;
	}
}
